home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / MEMORY_.H < prev    next >
C/C++ Source or Header  |  1992-03-05  |  3KB  |  86 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* memory_.h */
  21. /* Generic substitute for Unix memory.h */
  22.  
  23. /****** Note: the System V bcmp routine only returns zero or non-zero, ******/
  24. /****** unlike memcmp which returns -1, 0, or 1. ******/
  25.  
  26. #ifdef __TURBOC__
  27. /* The Turbo C implementation of memset swaps the arguments and calls */
  28. /* the non-standard routine setmem.  We may as well do it in advance. */
  29. #  undef memset                /* just in case */
  30. #  include <mem.h>
  31. #  define memset(dest,chr,cnt) setmem(dest,cnt,chr)
  32. #else
  33. #  ifdef VMS
  34.     extern char *memcpy(), *memset();
  35.     extern int memcmp();
  36. #  else
  37. #    if defined(BSD4_2) || defined(UTEK)
  38.     extern bcopy(), bcmp(), bzero();
  39. #       define memcpy(dest,src,len) bcopy(src,dest,len)
  40. #       define memcmp(b1,b2,len) bcmp(b1,b2,len)
  41.     /* Define our own version of memset */
  42. #    if defined(__STDC__) && !defined(UTEK)
  43.     static void memset(void *dest, register char ch, unsigned len)
  44. #    else
  45.     static void memset(dest, ch, len)
  46.       char *dest; register char ch; unsigned len;
  47. #    endif                /* (!)__STDC__, ... */
  48.        {    if ( ch == 0 )
  49.             bzero(dest, len);
  50.         else if ( len > 0 )
  51.            {    register char *p = (char *)dest;
  52.             register unsigned count = len;
  53.             do { *p++ = ch; } while ( --count );
  54.            }
  55.        }
  56. #    else                /* !BSD4_2 */
  57. #      if defined(_POSIX_SOURCE) || defined(_HPUX_SOURCE) || defined(__WATCOMC__)
  58. #        include <string.h>
  59. #      else
  60. #        include <memory.h>
  61. #      endif                /* !_POSIX_SOURCE, ... */
  62. #    endif                /* !BSD4_2, ... */
  63. #  endif                /* !VMS */
  64. #endif                    /* !__MSDOS__ */
  65.  
  66. /* memswab is not a standard routine.  It swaps bytes in 16-bit words. */
  67. /* We thought we would come out ahead by using the Watcom C `swab' */
  68. /* library routine, but it's slower than the C routine in gsmisc.c! */
  69. /* Note that the arguments are declared char *, */
  70. /* but the implementation may assume they are int-aligned. */
  71. #ifdef __PROTOTYPES__
  72. extern void memswab(const char *src, char *dest, int count);
  73. #else
  74. extern void memswab();
  75. #endif
  76.  
  77. /* memflip8x8 transposes an 8 x 8 block of bits. */
  78. /* line_size is the raster of the input data; */
  79. /* dist is the distance between output bytes. */
  80. /* Dot matrix printers need this.  The C code is in gsmisc.c. */
  81. #ifdef __PROTOTYPES__
  82. extern void memflip8x8(const byte *inp, int line_size, byte *outp, int dist);
  83. #else
  84. extern void memflip8x8();
  85. #endif
  86.